///
/// @ProjectName:    learning_rust
/// @Description:    
/// @File:           jz3.rs
/// @Author:         wujehy
/// @Email:          wujehy@qq.com
/// @Time:           2021-06-30 21:54
///
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct ListNode {
    pub val: i32,
    pub next: Option<Box<ListNode>>,
}

impl ListNode {
    #[inline]
    #[allow(dead_code)]
    fn new(val: i32) -> Self {
        ListNode {
            val: val,
            next: None,
        }
    }
}


struct Solution {}

impl Solution {

    fn new() -> Self {
        Solution {}
    }

    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * @param head ListNode类
     * @return int整型一维数组
     */
    #[allow(non_snake_case)]
    pub fn printListFromTailToHead(&self, head: Option<Box<ListNode>>) -> Vec<i32> {
        match head {
            None => {
                return Vec::new();
            }
            Some(node) => {
                let mut result = self.printListFromTailToHead(node.next);
                result.push(node.val);
                return result;
            }
        }
    }
}


#[test]
fn test3() {
    let s = Solution::new();
    let expext = vec! {3, 2, 1};
    let lists = Option::Some(Box::new(ListNode {
        val: 1,
        next:
        Option::Some(Box::new(ListNode {
            val: 2,
            next:
            Option::Some(Box::new(ListNode {
                val: 3,
                next: None,
            })),
        })),
    }));

    assert_eq!(expext, s.printListFromTailToHead(lists));
}